#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    const int dx[4] = { 1,0,-1,0 };
    const int dy[4] = { 0,1,0,-1 };
    void dfs(vector<vector<int>>& image, int sr, int sc, int color, int curcolor) {
        for (int i = 0; i < 4; i++)
        {
            if (sr + dx[i] < image.size() && sc + dy[i] < image[0].size())
            {
                if (image[sr + dx[i]][sc + dy[i]] == curcolor) {
                    image[sr + dx[i]][sc + dy[i]] = color;
                    dfs(image, sr + dx[i], sc + dy[i], color, curcolor);
                }
                
            }
            
        }
    }
    vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int color) {
        int curcolor = image[sr][sc];
        image[sr][sc] = color;
        dfs(image, sr, sc, color, curcolor);
        return image;
    }
};
int main()
{
    Solution s;
    vector<vector<int>> image = { {0,0,0 }, { 0,0,0 } };
    s.floodFill(image, 0, 0, 0);
    return 0;
}